Span-based joint extraction model shares the semantic representation of entity spans in entity and Relation Extraction (RE) tasks, which effectively reduces the cascade error caused by pipeline models. However, the existing models cannot adequately integrate contextual information into the representation of entities and relations. To solve this problem, a Joint Entity and Relation extraction model based on Contextual semantic Enhancement (JERCE) was proposed. Firstly, the semantic feature representations of sentence-level text and inter-entity text were obtained by contrastive learning method. Then, the representations were added into the representations of entity and relation to predict entities and relations jointly. Finally, the loss values of the two tasks were adjusted dynamically to optimize the overall performance of the joint model. In experiments on public datasets CoNLL04, ADE and ACE05, compared with Trigger-sense Memory Flow framework (TriMF), the proposed JERCE model has the F1 scores of entity recognition improved by 1.04, 0.13 and 2.12 percentage points respectively, and the F1 scores of RE increased by 1.19, 1.14 and 0.44 percentage points respectively. Experimental results show that the JERCE model can fully obtain semantic information in context.